package cn.tedu.basic;

import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.Scanner;

//测试BigDecimal，小数运算
public class Test5_BigD {
    public static void main(String[] args) {
        Method();
        Method2();
        method3();
        Method4();

    }
    public static void Method(){
        double a =new Scanner(System.in).nextDouble();
        double b =new Scanner(System.in).nextDouble();
        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/b);
        //不精确
    }
    public static void Method2(){
        double a =new Scanner(System.in).nextDouble();
        double b =new Scanner(System.in).nextDouble();
        BigDecimal b1 =new BigDecimal(a+"");
        BigDecimal b2 =new BigDecimal(b+"");
        System.out.println(b1.add(b2));//加
        System.out.println(b1.subtract(b2));//减
        System.out.println(b1.multiply(b2));//乘
        System.out.println(b1.divide(b2,3,BigDecimal.ROUND_HALF_UP));//除
        //double 不精确

    }
    public static void method3(){
        double x =new Scanner(System.in).nextDouble();
        double y =new Scanner(System.in).nextDouble();
        BigDecimal bx =new BigDecimal(x+"");
        BigDecimal by =new BigDecimal(y+"");
        System.out.println(bx.subtract(by));
        System.out.println(bx.add(by));
        System.out.println(bx.multiply(by));
        System.out.println(bx.divide(by,3,BigDecimal.ROUND_HALF_UP));
    }
    public static void Method4(){
        double m =new Scanner(System.in).nextDouble();
        double n =new Scanner(System.in).nextDouble();
        BigDecimal mm =new BigDecimal(m+"");
        BigDecimal nn =new BigDecimal(n+"");
        System.out.println(mm.add(nn));
        System.out.println(mm.subtract(nn));
        System.out.println(mm.multiply(nn));
        System.out.println(mm.divide(nn,3,BigDecimal.ROUND_HALF_UP));
    }

}
